package com.ordertracker;

import com.ordertracker.persistent.dictionary.Client;
import com.ordertracker.persistent.dictionary.Employee;
import com.ordertracker.persistent.dictionary.User;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Description of class.
 * Created 1/9/13 3:13 PM
 *
 * @author andrey.rodin@playtech.com
 */

public class Session implements Serializable {

    private static final long serialVersionUID = -6394958308527071239L;

    private String sessionId;
    private String sessionKey;
    private User user;
    private Date createDate;
    private Date lastAccessedDate;
    private Employee employee;
    private boolean secure;
    private String timezone;
    private String locale;
    private Map<String, String> properties;
    private Client client;

    public Session() {
    }

    public Session(String sessionId, String sessionKey, User user, Date createDate, Client client, String locale, String timezone) {
        this.sessionId = sessionId;
        this.sessionKey = sessionKey;
        this.user = user;
        this.createDate = createDate;
        this.client = client;
        this.locale = locale;
        this.timezone = timezone;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getSessionKey() {
        return sessionKey;
    }

    public void setSessionKey(String sessionKey) {
        this.sessionKey = sessionKey;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getLastAccessedDate() {
        return lastAccessedDate;
    }

    public void setLastAccessedDate(Date lastAccessedDate) {
        this.lastAccessedDate = lastAccessedDate;
    }

    public boolean isSecure() {
        return secure;
    }

    public void setSecure(boolean secure) {
        this.secure = secure;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public String getTimezone() {
        return timezone;
    }

    public void setTimezone(String timezone) {
        this.timezone = timezone;
    }

    public String getLocale() {
        return locale;
    }

    public void setLocale(String locale) {
        this.locale = locale;
    }

    public Map<String, String> getProperties() {
        return properties;
    }

    public void setProperties(Map<String, String> properties) {
        this.properties = properties;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Session)) return false;

        Session session = (Session) o;

        if (secure != session.secure) return false;
        if (client != null ? !client.equals(session.client) : session.client != null)
            return false;
        if (!createDate.equals(session.createDate)) return false;
        if (employee != null ? !employee.equals(session.employee) : session.employee != null) return false;
        if (lastAccessedDate != null ? !lastAccessedDate.equals(session.lastAccessedDate) : session.lastAccessedDate != null)
            return false;
        if (!locale.equals(session.locale)) return false;
        if (properties != null ? !properties.equals(session.properties) : session.properties != null) return false;
        if (!sessionId.equals(session.sessionId)) return false;
        if (!sessionKey.equals(session.sessionKey)) return false;
        if (!timezone.equals(session.timezone)) return false;
        if (!user.equals(session.user)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = sessionId.hashCode();
        result = 31 * result + sessionKey.hashCode();
        result = 31 * result + user.hashCode();
        result = 31 * result + createDate.hashCode();
        result = 31 * result + (lastAccessedDate != null ? lastAccessedDate.hashCode() : 0);
        result = 31 * result + (employee != null ? employee.hashCode() : 0);
        result = 31 * result + (secure ? 1 : 0);
        result = 31 * result + timezone.hashCode();
        result = 31 * result + locale.hashCode();
        result = 31 * result + (properties != null ? properties.hashCode() : 0);
        result = 31 * result + (client != null ? client.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Session{" +
                "sessionId='" + sessionId + '\'' +
                ", sessionKey=" + sessionKey +
                ", user=" + user +
                ", createDate=" + createDate +
                ", lastAccessedDate=" + lastAccessedDate +
                ", employee=" + employee +
                ", timezone='" + timezone + '\'' +
                ", locale='" + locale + '\'' +
                ", client='" + client + '\'' +
                '}';
    }
}
